﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace UMLObjects
{
    public class Arrow : IArrow, IUMLObject, INotifyPropertyChanged
    {
        private string name = "";

        private Point startPosition;
        private Point endPosition;
        private IUMLObject pointsTo;
        private IUMLObject pointsFrom;

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        //Receive/send name. If empty insert "Insert name".
        public string Name
        {
            get { return name; }
            set
            {
                name = (value == "") ? "" : value;
                NotifyPropertyChanged("Name");
            }
        }

        //Receive/send start position
        public Point StartPosition
        {
            get { return startPosition; }
            set
            {
                startPosition = value;
                NotifyPropertyChanged("StartPosition");
            }
        }

        //Receive/send end position
        public Point EndPosition
        {
            get { return endPosition; }
            set
            {
                endPosition = value;
                NotifyPropertyChanged("EndPosition");
            }
        }

        //copy of start position to live up to the IUMLObject
        public Point Position
        {
            get { return startPosition; }
            set
            {
                startPosition = value;
                NotifyPropertyChanged("Position");
            }
        }

        //get/set the IUMLObject that the arrow is pointing to
        public IUMLObject PointsTo
        {
            get { return pointsTo; }
            set
            {
                pointsTo = value;
                NotifyPropertyChanged("PointsTo");
            }
        }

        //get/set the IUMLObject that the arrow is pointing from
        public IUMLObject PointsFrom
        {
            get { return pointsFrom; }
            set
            {
                pointsFrom = value;
                NotifyPropertyChanged("PointsFrom");
            }
        }

    }
}
